/**
 * 兼容性封装
 * 滚动条在Y轴上的滚动距离（被卷去的距离）
 * @param targetElement 可以指定目标元素
 * @returns {number}
 */
export default function getScrollTop(targetElement){
    var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
    if(targetElement){
        scrollTop=targetElement.scrollTop;
    }else {
        if (document.body) {
            bodyScrollTop = document.body.scrollTop;
        }
        if (document.documentElement) {
            documentScrollTop = document.documentElement.scrollTop;
        }
        scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
    }
    return scrollTop;
}